#include "fake_inno_log_cpp.h"
// #include <spdlog/async.h>
#include <spdlog/sinks/basic_file_sink.h>
// #include <spdlog/sinks/rotating_file_sink.h>
#include <spdlog/sinks/stdout_sinks.h>
#include <spdlog/spdlog.h>
#include <memory>

namespace Fake {

static std::shared_ptr<spdlog::logger> slogger;
void inno_spd_log(const std::string& log_file, const std::string& log_func, int32_t log_line, InnoLogLevel log_lv,
             const std::string& log_msg) {
  spdlog::level::level_enum spdlog_lev{spdlog::level::level_enum::info};
  if (log_lv == InnoLogLevel::INNOLOG_LEVEL_ERROR) {
    spdlog_lev = spdlog::level::level_enum::err;
  }
  slogger->log(spdlog::source_loc{log_file.c_str(), log_line, log_func.c_str()}, spdlog_lev, log_msg);
}

void init_logger() {
  const auto& console_sink = std::make_shared<spdlog::sinks::stdout_sink_mt>();

  const auto& file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>("logfile.txt", true);

  spdlog::set_pattern("[%Y-%m-%d %H:%M:%S] [%^%l%$] [thread %t] %v");

  slogger = std::make_shared<spdlog::logger>("logger_name", spdlog::sinks_init_list({console_sink, file_sink}));

  slogger->set_level(spdlog::level::trace);
}
}  // namespace Fake
